#include "Mesh.h"
#include <gl\glew.h>
#include "ILayout.h"


Mesh::Mesh(void)
{

}


Mesh::~Mesh(void)
{
	Dispose();
}

void Mesh::Dispose()
{
	vBuffer.Dispose();
	iBuffer.Dispose();
}
void Mesh::Draw()
{
	bbList.Bind();
	glDrawArrays(GL_TRIANGLES,0,vCount);
	bbList.Unbind();
}
void Mesh::DrawIndexed()
{
	bbList.Bind();
	glDrawElements(GL_TRIANGLES,iCount,GL_UNSIGNED_INT,(void*)0);
	bbList.Unbind();
}

void Mesh::SetVertexData(void * data,unsigned int size,int vertexCount,Usage usage)
{
	vBuffer.Bind();
	vBuffer.BufferData(size,data,usage);
	vCount = vertexCount;
}
void Mesh::SetIndexData(void * data,unsigned int size,int indexCount,Usage usage)
{
	iBuffer.Bind();
	iBuffer.BufferData(size,data,usage);
	iCount = indexCount;
}

void Mesh::BeginSetUp()
{
	bbList.Bind();
}
void Mesh::EndSetUp()
{
	bbList.Unbind();
}

void Mesh::SetLayout(ILayout * layout)
{
	layout->Bind();
}

